interface LoginParams {
  username: string
  password: string
}
interface Response<V> {
  code: number
  message: string
  data: V
}

interface LoginData {
  token: string
  expiresIn: number
  user: {
    userId: number
    username: string
    avatar: string
    desc: string
    roles: string[]
  }
}

interface UserInfo {
  userId: number
  username: string
  avatar: string
  desc: string
  roles: string[]
  buttons: string[]
  routes: string[]
}

interface UserListParams {
  page?: number
  pageSize?: number
  keyword?: string
}

interface UserListData {
  users: UserInfo[]
  total: number
  page: number
  pageSize: number
  totalPages: number
}

interface CreateUserParams {
  username: string
  password: string
  desc?: string
  roles?: string[]
  buttons?: string[]
  routes?: string[]
}

interface CreateUserData {
  message: string
  user: UserInfo
}

interface UpdateUserParams {
  username?: string
  desc?: string
  roles?: string[]
  buttons?: string[]
  routes?: string[]
}

interface UpdateUserData {
  message: string
  user: UserInfo
}

interface ChangePasswordParams {
  oldPassword: string
  newPassword: string
}

interface ChangePasswordData {
  message: string
}

interface UserStats {
  totalUsers: number
  roleStats: Record<string, number>
  onlineUsers: number
}

interface LogoutData {
  message: string
}

interface DeleteUserData {
  message: string
}

// 使用 Response 类型的响应接口
type LoginResponse = Response<LoginData>
type UserListResponse = Response<UserListData>
type CreateUserResponse = Response<CreateUserData>
type UpdateUserResponse = Response<UpdateUserData>
type ChangePasswordResponse = Response<ChangePasswordData>
type UserStatsResponse = Response<UserStats>
type LogoutResponse = Response<LogoutData>
type DeleteUserResponse = Response<DeleteUserData>
type UserInfoResponse = Response<UserInfo>
export type {
  LoginParams,
  Response,
  LoginData,
  LoginResponse,
  UserInfo,
  UserListParams,
  UserListData,
  UserListResponse,
  CreateUserParams,
  CreateUserData,
  CreateUserResponse,
  UpdateUserParams,
  UpdateUserData,
  UpdateUserResponse,
  ChangePasswordParams,
  ChangePasswordData,
  ChangePasswordResponse,
  UserStats,
  UserStatsResponse,
  LogoutData,
  LogoutResponse,
  DeleteUserData,
  DeleteUserResponse,
  UserInfoResponse
}
